<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE html>
<html lang="en">
	<head>
	<base href="<%=basePath%>"><!-- jsp文件头和头部 -->
	<%@ include file="../../system/admin/top.jsp"%> 
	</head>
<body>
			<!-- 检索  -->
			<form action="expensereimbursement/list.do" method="post" name="Form" id="Form">
			<div class="con-form">
			       <input type="text" placeholder="输入查询内容"  autocomplete="off" id="nav-search-input" type="text"  name="keyWord" value="${pd.keyWord }"  class="input-search">
			    开始日期 <input type="text" name="lastLoginStart" id="lastLoginStart" class="form_datetime date" value="${pd.lastLoginStart}" readonly="readonly">
                                        结束日期 <input type="text" name="lastLoginEnd" id="lastLoginEnd" class="form_datetime date" value="${pd.lastLoginEnd}" readonly="readonly">
			<!-- 检索  -->
		
		    <button class="search" onclick="search();" title="查询">查询</button>
		    </div>
			    <p class="operate">
			        <a class="create Operate" title="新增" onclick="add();">申请报销</a>
			    </p>
			<table>
				 <colgroup>
		            <col width="2%">
		            <col width="5%">
<%-- 		        <col width="9%"> --%>
		            <col width="9%">
		            <col width="9%">
		            <col width="9%">
		            <col width="10%">
		            <col width="13%">
		            <col width="13%">
		        </colgroup>
				<thead>
					<tr>
						<th><input type="checkbox" id="zcheckbox"></th>
						<th class="center">序号</th>
<!-- 					<th class="center">申请报销原因</th> -->
						<th class="center">申请人</th>
						<th class="center">申请部门</th>
						<th class="center">申请报销时间</th>
						<th class="center">申请报销金额</th>
						<th class="center">状态</th>
						<th class="center">操作</th>
					</tr>
				</thead>
										
				<tbody>
					
				<!-- 开始循环 -->	
				<c:choose>
					<c:when test="${not empty varList}">
						<c:if test="${QX.cha == 1 }">
						<c:forEach items="${varList}" var="var" varStatus="vs">
							<tr>
								<td class='center' style="width: 30px;">
									<label><input type='checkbox' name='ids' value="${var.er_id}" /><span class="lbl"></span></label>
								</td>
								<td class='center' style="width: 30px;">${vs.index+1}</td>
								<td><a style="color:#ff8810" href="${basePath}expensereimbursement/goDetail.do?er_id=${var.er_id }">${var.USERNAME}</a></td>
								<td>${var.department_name}</td>
								<td><fmt:formatDate value="${var.er_apply_time}" pattern="yyyy-MM-dd HH:mm:ss"/></td>
								<td>${var.er_apply_amount}</td>
								<td>
								  <c:if test="${var.er_status == 0}">保存</c:if>
								  <c:if test="${var.er_status == 1}">提交流程</c:if>
								  <c:if test="${var.er_status == 2}"><span style="color: red;">审核驳回</span></c:if>
								  <c:if test="${var.er_status == 3}"><span style="color: blue;">审核通过</span></c:if>
								  <c:if test="${var.er_status == 4}"><span style="color: green;">确认报销</span></c:if>
								</td>
								<td>
							    	<c:if test="${QX.edit != 1 && QX.del != 1 }">
										<div class="operate-more">
					                        <span class='operate-true'></span>
				                    	</div>
									</c:if>
									<c:if test="${QX.edit == 1 || QX.del == 1 }">
			                        	<c:if test="${QX.edit == 1 && var.er_status == 0 && pd.userId==var.user_id}">
											<p class="operate">
												<a class="operatea revise" title="修改"  onclick="edit('${var.er_id}');">修改</a>
												<%-- <a class="operatea revise" title="提交流水" onclick="submissionProcess('${var.er_id}');"></a> --%>
												<a class="operatea delete" title="删除"  onclick="del('${var.er_id}');">删除</a>
											</p>
										</c:if>
										<c:if test="${QX.del == 1 && var.er_status == 3}">
											<p class="operate">
												<a class="operatea revise" title="确认报销" onclick="confirmExpense('${var.er_id}');">确认报销</a>
											</p>
										</c:if>
				                    </c:if>
							    </td>
							</tr>
						</c:forEach>
						</c:if>
						<c:if test="${QX.cha == 0 }">
							<tr>
								<td colspan="100" class="center">您无权查看</td>
							</tr>
						</c:if>
					</c:when>
					<c:otherwise>
						<tr class="main_info">
							<td colspan="100" class="center" >没有相关数据</td>
						</tr>
					</c:otherwise>
				</c:choose>
			</tbody>
		</table>
	<!--分页器-->
    <div class="branchPage">${page.pageStr}</div>
</form>
		<script type="text/javascript">
		$(function() {
			//日期插件
			$(".form_datetime").datetimepicker( {
			     autoclose:true,
			     format: "yyyy-mm-dd",
			     language: 'cn',
			     clearBtn:true,
			     todayHighlight: true
			});
			
		});
		//检索
		function search(){
			$("#Form").submit();
		}
		
		//新增
	    function add(){
			$("#zhongxin",domObj).show();
			$("#zhongxin iframe",domObj).attr("src","<%=basePath%>expensereimbursement/goAdd.do");
		}
		
		
		//修改
		function edit(Id){
			$("#zhongxin",domObj).show();
			$("#zhongxin iframe",domObj).attr("src","<%=basePath%>expensereimbursement/goEdit.do?er_id="+Id);
		}
		
		
		
		//提交流程
		function submissionProcess(Id){
			$.confirm('确定要提交流程了吗?',null,function(type){
		        if(type==='yes'){
					var url = "<%=basePath%>expensereimbursement/updateStatus.do?er_id="+Id+"&er_status=1&tm="+new Date().getTime();
					$.get(url,function(data){
						if(data == "success"){
							//刷新列表页面
							location.href='<%=basePath%>expensereimbursement/list.do';
						}
					});
		        }else{
		           //do Nothing
		        }
		        this.hide();
		    });
		}
		
		
		//确认报销
		function confirmExpense(Id){
			$.confirm('确认已经报销了吗?',null,function(type){
		        if(type==='yes'){
					var url = "<%=basePath%>expensereimbursement/updateStatus.do?er_id="+Id+"&er_status=4&tm="+new Date().getTime();
					$.get(url,function(data){
						if(data == "success"){
							//刷新列表页面
							location.href='<%=basePath%>expensereimbursement/list.do';
						}
					});
		        }else{
		           //do Nothing
		        }
		        this.hide();
		    });
		}
		
		
		
		
		//删除
		function del(Id){
			$.confirm('确认删除吗?',null,function(type){
		        if(type==='yes'){
					var url = "<%=basePath%>expensereimbursement/delete.do?er_id="+Id+"&tm="+new Date().getTime();
					$.get(url,function(data){
						if(data == "success"){
							//刷新列表页面
							location.href='<%=basePath%>expensereimbursement/list.do';
						}
					});
		        }else{
		           //do Nothing
		        }
		        this.hide();
		    });
		}
		
		
		</script>
		
	</body>
</html>

